// 边缘碰撞封装
const Frontier = {
    // 判断点在矩形内
    rectIn: (x, y, rect) => {
        return x >= rect[0] && x <= (rect[0] + rect[2]) &&
            y >= rect[1] && y <= (rect[1] + rect[3]);
    },
    // 判断两矩形相邻或相交
    rectWith: (obj1, obj2) => {
        const tw2 = (obj1.w + obj2.w) / 2;
        const th2 = (obj1.h + obj2.h) / 2;
        return Math.abs(obj1.x - obj2.x) <= tw2 &&
            Math.abs(obj1.y - obj2.y) <= th2;
    }
}
console.log("Frontier", Frontier);